<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="maximum-scale=1.0,minimum-scale=1.0,user-scalable=0,width=device-width,initial-scale=1.0"/>
    <meta name="format-detection" content="telephone=no,email=no,date=no,address=no">
    <title>随手快递</title>
    <link rel="stylesheet" type="text/css" href="../../myCss/commes.css" />
    <link rel="stylesheet" href="../../myCss/photoswipe.css"/>
    <link rel="stylesheet" href="../../myCss/default-skin/default-skin.css"/>
    <link rel="stylesheet" type="text/css" href="../../AUI/css/aui.css" />
    <link rel="stylesheet" type="text/css" href="../../font-awesome/css/font-awesome.min.css" />
    <link rel="stylesheet" href="http://cache.amap.com/lbs/static/main1119.css"/>
    <style>
        /*遮罩层*/

        .mask {
            width: 100%;
            height: 100%;
            background: rgba(0, 0, 0, .5);
            position: fixed;
            top: 0;
            left: 0;
            z-index: 999;
            display: none;
        }

        .alert {
            width:75%;
            height: 100px;
            border-radius: .2rem;
            background: rgba(249, 249, 249, 0.98);
            font-size:16px;
            text-align: center;
            line-height: 100px;
            position: absolute;
            left: 50%;
            top: 50%;
            transform: translate(-50%, -50%);
        }
        input{
            border-bottom:1px solid #ddd;
            color: #484848;
            width:40%;
        }
        .money{
            width: 15%;
            height: 20px;
            float: right;
            margin-right: 5px;
            margin-top: 2px;
        }
        .disc{
            text-align: center;
            padding-bottom:4px ;
            font-size:17px;
            background: #fff;

        }
        .d1{
            color: rgba(41, 179, 166, 0.95);
        }
        textarea{
            font-size: 15px;
            font-family: 微软雅黑;
            color: #5a5a5a;
        }
        .note{
            position: fixed;
            top: 45px;
            height:30px;
            width: 100%;
            background-color: rgba(66, 81, 93, 0.81);
            color: #fff;
            font-size: 13px;
            z-index: 9999;
            padding-left: 15px;
            line-height: 30px;
        }
    </style>
    <style>
        * {
            margin: 0;
            padding: 0;
        }
        /*图片上传*/

        html,
        body {
            width: 100%;
            height: 100%;
        }

        .container {
            width: 100%;
            height: 100%;
            overflow: auto;
            clear: both;
        }

        .z_photo {
            width: 100%;
            padding-bottom: 12px;
            overflow: auto;
            clear: both;
            margin: auto;
            background: #fff;
            border: 0;
        }



        .z_file {
            width: 60px;
            height: 60px;
            background: url(../../myImage/z_add.png) no-repeat;
            background-size: 100% 100%;
            float: left;
            margin-right: 0.2rem;
            margin-top: 5px;
        }

        .z_file input::-webkit-file-upload-button {
            width: 60px;
            height: 60px;
            border: none;
            position: absolute;
            outline: 0;
            opacity: 0;
        }

        .z_file input{
            border:0;
        }

        /*遮罩层*/

        .z_mask {
            width: 100%;
            height: 100%;
            background: rgba(0, 0, 0, .5);
            position: fixed;
            top: 0;
            left: 0;
            z-index: 999;
            display: none;
        }

        .z_alert {
            width:170px;
            height: 100px;
            border-radius: .2rem;
            background: #fff;
            font-size:15px;
            text-align: center;
            position: absolute;
            left: 50%;
            top: 50%;
            transform: translate(-50%, -50%);
        }

        .z_alert p:nth-child(1) {
            line-height: 70px;
        }

        .z_alert p:nth-child(2) span {
            display: inline-block;
            width: 49%;
            height: 28px;
            line-height: 28px;
            float: left;
            border-top: 1px solid #ddd;
        }

        .z_cancel {
            border-right: 1px solid #ddd;
        }

    </style>
</head>
<body style="font-family: 微软雅黑">
<div class="mask">
    <!--弹出框-->
    <div class="alert">
        <p id="words"></p>
    </div>
</div>
<div id='pubBuy' style="display:block;">
    <header class="aui-bar aui-bar-nav" id="aui-header">
        <a class="aui-btn aui-pull-left" tapmode onclick="history.back();">
            <span class="aui-iconfont aui-icon-left"></span>
        </a>
        <div class="aui-title">发布购买请求</div>
    </header>
    <div class="note">指定发布给：旧事不挽用户</div>
    <section class="aui-content" style="margin-top: 80px">
        <div class="aui-card-list-content-padded">
            <div class="disc"><span class="d1">· · · ❃ </span>
                <span style="font-family: 幼圆;">商品描述</span>
                <span class="d1"> ❃ · · ·</span>
            </div>
            <ul class="aui-list aui-form-list">
                <li class="aui-list-item">
                    <div class="aui-list-item-inner">
                        <div class="aui-list-item-input">
                            <textarea placeholder="请输入商品名称" id="tradeName"></textarea>
                        </div>
                    </div>
                </li>
                <li class="aui-list-item">
                    <div class="aui-row aui-row-padded">
                        <div class="z_photo">
                            <div class="my-gallery" id="tradeImg">
                            </div>
                            <div class="z_file" id="z_file">
                                <input type="file" id="head_file_ipt1" name="files" multiple onChange="ajaxFileUpload1();"  />
                            </div>
                        </div>
                    </div>
                </li>
            </ul>

        </div>
        <div class="aui-card-list-content-padded  ">
            <div class="disc"><span class="d1">· · · ❃ </span>
                <span style="font-family: 幼圆;">店铺描述</span>
                <span class="d1"> ❃ · · ·</span>
            </div>
            <ul class="aui-list aui-form-list">
                <li class="aui-list-item">
                    <div class="aui-list-item-inner">
                        <div class="aui-list-item-input">
                            <textarea placeholder="请输入店铺名称" id="purchaseStore"></textarea>
                        </div>
                    </div>
                </li>
                <li class="aui-list-item">
                    <div class="aui-row aui-row-padded">
                        <div class="z_photo">
                            <div class="my-gallery" id="purchaseImg">
                            </div>
                            <div class="z_file" id="z_file1">
                                <input type="file" id="head_file_ipt" name="files" multiple onChange="ajaxFileUpload();"  />
                            </div>
                        </div>
                    </div>
                </li>
            </ul>

        </div>
        <div class="aui-card-list-content-padded aui-margin-b-15 aui-list-item-arrow" style="background: #fff;border-bottom: 1px solid #ddd">
            <div id="storeMap" style="margin: 0 0 10px 0;font-size: 15px;" ><span class="fa fa-map-marker" ></span><span style="margin-left: 10px"><input id="purchasePlace"  placeholder="店铺地址" style="border: 0;width: 80%" readonly></span></div>
        </div>

    </section>
    <section class="aui-content">
        <div class="aui-card-list aui-list-item-arrow" onclick="changeAddr()"  style="border-bottom: 1px solid #ddd">
            <div class="aui-card-list-content-padded"style="height: 70px">
                <div style="font-size: 15px" ><span >收货地址</span>
                    <span style="float: right;margin-right:13px;color: rgb(107, 107, 107)" id="address" addressId=""></span>
                </div>
                <div style="font-size: 14px;margin-top: 5px;color: rgb(161, 161, 161)" >
                    <span style="float: right;margin-right:13px;"><span id="name" style="padding-right: 3px"></span> <span id="phone"></span></span>
                </div>
            </div>
        </div>
    </section>
    <section class="aui-content">
        <div class="aui-card-list">
            <div class="aui-card-list-content-padded aui-border-b aui-border-t">
                <div style="font-size: 15px" ><span >期望送达时间</span>

                    <div class="settings" style="display:none;">
                        <select name="demo" id="demo">
                            <option value="date">日期</option>
                        </select>
                    </div>
                    <input style="float: right;text-align: right" name="time" id="time" class="demo-test-date demo-test-datetime demo-test-time demo-test-credit" />

                </div>
            </div>
        </div>
    </section>
    <section class="aui-content" >
        <div class="aui-card-list ">
            <div class="aui-card-list-content-padded aui-border-b aui-border-t aui-list-item-arrow">
                <div style="font-size: 15px;margin-bottom: 5px" onclick="openActionsheet()">
                    <span>愿付小费</span><span style="font-size: 11px"></span>
                    <input id="tips" style="border:0;float: right;text-align: right;padding:3px 20px 0 0" readonly value="0元">
                </div>
            </div>
            <div class="aui-card-list-content-padded aui-border-b aui-border-t aui-list-item-arrow">
                <div style="font-size: 15px;margin-bottom: 5px" onclick="openActionsheet1()">
                    <span>预估商品金额</span><span style="font-size: 11px"></span>
                    <input id="goods" style="width:80px;border:0;float: right;text-align: right;padding:3px 20px 0 0" readonly value="0元">
                </div>
            </div>
            <div class="aui-card-list-content-padded aui-border-b aui-border-t aui-list-item-arrow">
                <div style="font-size: 15px" onclick="openActionsheet2()">
                    <span>快递费</span>
                    <input id="express" style="width:80px;border:0;float: right;text-align: right;padding:3px 20px 0 0" readonly value="10元">

                </div>
            </div>
        </div>
    </section>
    <section class="aui-content">
        <div class="aui-card-list">
            <div class="aui-card-list-content-padded aui-border-b aui-border-t">
                <div style="font-size: 15px" ><span class="fa fa-tag"></span><span style="margin-left: 10px">备注</span>
                    <ul class="aui-list aui-form-list">
                        <li class="aui-list-item">
                            <div class="aui-list-item-inner">
                                <div class="aui-list-item-input" ><textarea id="note" style="font-size: 13px" placeholder="想说点什么呢..."></textarea>
                                </div>
                            </div>
                        </li>
                    </ul>
                </div>

            </div>
        </div>
    </section>
    <section class="aui-content" >
        <div class="aui-card-list">
            <div class="aui-btn aui-btn-success aui-btn-block aui-btn-outlined aui-btn-sm" tapmode id="pubOrder">发布</div>
        </div>
    </section>
</div>
<div id="addr" style="display: none;overflow:hidden">
    <header class="aui-bar aui-bar-nav" >
        <a class="aui-btn aui-pull-left" tapmode onclick="back()">
            <span class="aui-iconfont aui-icon-left"></span>
        </a>
        <div class="aui-title">收货地址</div>
    </header>

    <div style="margin-top: 45px">
        <ul class="aui-list aui-media-list" id="addressUl">
        </ul>
    </div>
</div>
<div  id="map" style="display: none;overflow:hidden">
    <header class="aui-bar aui-bar-nav" style="background: #fff">
        <a class="aui-btn aui-pull-right" tapmode onclick="backMap()">
            <span class="aui-iconfont aui-icon-down" style="color: #515151"></span>
        </a>
        <div id="myPageTop" style="padding: 0 5px;top:0px;margin: 0;border: 0;width: 100%">
            <label style="margin: 0">请输入关键字：</label>
            <input id="tipinput" style="height: 30px;width: 60%"/>
        </div>
    </header>
    <div id="container" style="margin-top: 45px"></div>
    <div id="tip"></div>
</div>
<div class="pswp" tabindex="-1" role="dialog" aria-hidden="true">
    <div class="pswp__bg"></div>
    <div class="pswp__scroll-wrap">
        <div class="pswp__container">
            <div class="pswp__item"></div>
            <div class="pswp__item"></div>
            <div class="pswp__item"></div>
        </div>
        <div class="pswp__ui pswp__ui--hidden">
            <div class="pswp__top-bar">
                <div class="pswp__counter"></div>
                <button class="pswp__button pswp__button--close" title="Close (Esc)"></button>
                <div class="pswp__preloader">
                    <div class="pswp__preloader__icn">
                        <div class="pswp__preloader__cut">
                            <div class="pswp__preloader__donut"></div>
                        </div>
                    </div>
                </div>
            </div>
            <div class="pswp__share-modal pswp__share-modal--hidden pswp__single-tap">
                <div class="pswp__share-tooltip"></div>
            </div>
            <button class="pswp__button pswp__button--arrow--left" title="Previous (arrow left)"></button>
            <button class="pswp__button pswp__button--arrow--right" title="Next (arrow right)"></button>
            <div class="pswp__caption">
                <div class="pswp__caption__center"></div>
            </div>
        </div>
    </div>
</div>

<script type="text/javascript" src="../../AUI/script/api.js" ></script>
<script type="text/javascript" src="../../myJs/jquery-1.12.1.min.js" ></script>
<script src="../../myJs/jquery.cookie.js"></script>
<script src="../../myJs/ajaxfileupload.js"></script>
<script src="../../myJs/mobiscroll.2.13.2.js"></script>
<link href="../../myCss/mobiscroll.2.13.2.css" rel="stylesheet" >
<script type="text/javascript" src="../../myJs/index.js" ></script>
<script type="text/javascript" src="../../AUI/script/aui-actionsheet.js" ></script>
<script type="text/javascript" src="http://webapi.amap.com/maps?v=1.3&key=a37424dd342449fb8ab5f809081e01ce&plugin=AMap.Autocomplete,AMap.PlaceSearch"></script>
<script type="text/javascript" src="http://cache.amap.com/lbs/static/addToolbar.js"></script>
<script src="../../myJs/photoswipe.min.js"></script>
<script src="../../myJs/photoswipe-ui-default.min.js"></script>
<script type="text/javascript">
    /***************************************
     由于Chrome、IOS10等已不再支持非安全域的浏览器定位请求，为保证定位成功率和精度，请尽快升级您的站点到HTTPS。
     ***************************************/
    var map, geolocation;
    //加载地图，调用浏览器定位服务
    map = new AMap.Map('container', {
        resizeEnable: true,
        zoom:11,
        center: [120.200268,30.248318]

    });
    var autoOptions = {
        input: "tipinput"
    };
    var auto = new AMap.Autocomplete(autoOptions);
    var placeSearch = new AMap.PlaceSearch({
        map: map
    });  //构造地点查询类
    AMap.event.addListener(auto, "select", select);//注册监听，当选中某条记录时会触发
    function select(e) {
        var s = JSON.stringify(e);
        alert(s);
        placeSearch.setCity(e.poi.adcode);
        placeSearch.search(e.poi.name);  //关键字查询查询
        console.log("lng"+ e.poi.location.lng);
        console.log("lat"+ e.poi.location.lat);
        console.log("name"+ e.poi.name);
        console.log("district"+ e.poi.district);
        $("#purchasePlace").val(e.poi.name);
        sessionStorage.setItem("storeLongitude", e.poi.location.lng);
        sessionStorage.setItem("storeLatitude", e.poi.location.lat);

    }
    /*    map.plugin('AMap.Geolocation', function() {
     geolocation = new AMap.Geolocation({
     enableHighAccuracy: true,//是否使用高精度定位，默认:true
     timeout: 10000,          //超过10秒后停止定位，默认：无穷大
     buttonOffset: new AMap.Pixel(10,20),//定位按钮与设置的停靠位置的偏移量，默认：Pixel(10, 20)
     zoomToAccuracy: true,      //定位成功后调整地图视野范围使定位位置及精度范围视野内可见，默认：false
     buttonPosition:'RB'
     });
     map.addControl(geolocation);
     geolocation.getCurrentPosition();
     AMap.event.addListener(geolocation, 'complete', onComplete);//返回定位信息
     AMap.event.addListener(geolocation, 'error', onError);      //返回定位出错信息
     });
     //解析定位结果
     function onComplete(data) {
     var str=['定位成功'];
     str.push('经度：' + data.position.getLng());
     str.push('纬度：' + data.position.getLat());
     if(data.accuracy){
     str.push('精度：' + data.accuracy + ' 米');
     }//如为IP精确定位结果则没有精度信息
     str.push('是否经过偏移：' + (data.isConverted ? '是' : '否'));
     document.getElementById('tip').innerHTML = str.join('<br>');
     }
     //解析定位错误信息
     function onError(data) {
     document.getElementById('tip').innerHTML = '定位失败';
     }*/
</script>
<!--输入金额-->
<script type="text/javascript">
    apiready = function(){
        api.parseTapmode();
    }
    var actionsheet = new auiActionsheet();
    function openActionsheet(){
        actionsheet.init({
            frameBounces:true,//当前页面是否弹动，（主要针对安卓端）
            title:'<div class="aui-text-center" style="padding:10px;line-height: 30px;font-size: 16px;font-family: 微软雅黑 Light">\
             <div onclick="pay(this)">0元</div>\
            <div onclick="pay(this)">5元</div>\
            <div onclick="pay(this)">10元</div>\
            <div onclick="pay(this)">15元</div>\
            <div onclick="pay(this)">20元</div>\
            <div >其他&nbsp;<input id="otherp" style="width: 40px;padding-left: 10px"><span class="fa fa-check aui-pull-right" style="padding: 12px 10px 0 0" onclick="payothers()"></span></div>\
        </div>'
        }, function(ret){

        })
    }
    function openActionsheet1(){
        actionsheet.init({
            frameBounces:true,//当前页面是否弹动，（主要针对安卓端）
            title:'<div class="aui-text-center" style="padding:10px;line-height: 30px;font-size: 16px;font-family: 微软雅黑 Light">\
            <div >商品金额&nbsp;&nbsp;<input id="num" style="width: 50px;text-align: center"><span class="fa fa-check aui-pull-right" style="padding: 12px 10px 0 0" onclick="paygoods()"></span></div>\
        </div>'
        }, function(ret){

        })
    }
    function openActionsheet2(){
        actionsheet.init({
            frameBounces:true,//当前页面是否弹动，（主要针对安卓端）
            title:'<div class="aui-text-center" style="padding:10px;line-height: 30px;font-size: 16px;font-family: 微软雅黑 Light">\
            <div >快递费&nbsp;&nbsp;<input id="num2" style="width: 50px;text-align: center"><span class="fa fa-check aui-pull-right" style="padding: 12px 10px 0 0" onclick="payex()"></span></div>\
        </div>'
        }, function(ret){

        })
    }

    function pay(node){
        //alert(node.innerHTML);
        actionsheet.close();
        $("#tips").val(node.innerHTML);
    }
    function payothers(){
        actionsheet.close();
        var otherp = $("#otherp").val();
        if(otherp==""){
            actionsheet.close();
        }else {
            actionsheet.close();
            $("#tips").val($("#otherp").val()+"元");
        }
    }
    function paygoods(){
        var goods = $("#num").val();
        if(goods==""){
            actionsheet.close();
        }else {
            actionsheet.close();
            $("#goods").val(goods+"元");
        }
    }
    function payex(){
        var express = $("#num2").val();
        if(express==""){
            actionsheet.close();
        }else {
            actionsheet.close();
            $("#express").val(express+"元");
        }
    }
</script>
<!--获取图片-->
<script type="text/javascript">
    var initPhotoSwipeFromDOM = function(gallerySelector) {

        // parse slide data (url, title, size ...) from DOM elements
        // (children of gallerySelector)
        var parseThumbnailElements = function(el) {
            var thumbElements = el.childNodes,
                    numNodes = thumbElements.length,
                    items = [],
                    figureEl,
                    linkEl,
                    size,
                    item;

            for (var i = 0; i < numNodes; i++) {

                figureEl = thumbElements[i]; // <figure> element

                // include only element nodes
                if (figureEl.nodeType !== 1) {
                    continue;
                }

                linkEl = figureEl.children[0]; // <a> element

                size = linkEl.getAttribute('data-size').split('x');

                // create slide object
                item = {
                    src: linkEl.getAttribute('href'),
                    w: parseInt(size[0], 10),
                    h: parseInt(size[1], 10)
                };



                if (figureEl.children.length > 1) {
                    // <figcaption> content
                    item.title = figureEl.children[1].innerHTML;
                }

                if (linkEl.children.length > 0) {
                    // <img> thumbnail element, retrieving thumbnail url
                    item.msrc = linkEl.children[0].getAttribute('src');
                }

                item.el = figureEl; // save link to element for getThumbBoundsFn
                items.push(item);
            }

            return items;
        };

        // find nearest parent element
        var closest = function closest(el, fn) {
            return el && (fn(el) ? el : closest(el.parentNode, fn));
        };

        // triggers when user clicks on thumbnail
        var onThumbnailsClick = function(e) {
            e = e || window.event;
            e.preventDefault ? e.preventDefault() : e.returnValue = false;

            var eTarget = e.target || e.srcElement;

            // find root element of slide
            var clickedListItem = closest(eTarget, function(el) {
                return (el.tagName && el.tagName.toUpperCase() === 'FIGURE');
            });

            if (!clickedListItem) {
                return;
            }

            // find index of clicked item by looping through all child nodes
            // alternatively, you may define index via data- attribute
            var clickedGallery = clickedListItem.parentNode,
                    childNodes = clickedListItem.parentNode.childNodes,
                    numChildNodes = childNodes.length,
                    nodeIndex = 0,
                    index;

            for (var i = 0; i < numChildNodes; i++) {
                if (childNodes[i].nodeType !== 1) {
                    continue;
                }

                if (childNodes[i] === clickedListItem) {
                    index = nodeIndex;
                    break;
                }
                nodeIndex++;
            }



            if (index >= 0) {
                // open PhotoSwipe if valid index found
                openPhotoSwipe(index, clickedGallery);
            }
            return false;
        };

        // parse picture index and gallery index from URL (#&pid=1&gid=2)
        var photoswipeParseHash = function() {
            var hash = window.location.hash.substring(1),
                    params = {};

            if (hash.length < 5) {
                return params;
            }

            var vars = hash.split('&');
            for (var i = 0; i < vars.length; i++) {
                if (!vars[i]) {
                    continue;
                }
                var pair = vars[i].split('=');
                if (pair.length < 2) {
                    continue;
                }
                params[pair[0]] = pair[1];
            }

            if (params.gid) {
                params.gid = parseInt(params.gid, 10);
            }

            return params;
        };

        var openPhotoSwipe = function(index, galleryElement, disableAnimation, fromURL) {
            var pswpElement = document.querySelectorAll('.pswp')[0],
                    gallery,
                    options,
                    items;

            items = parseThumbnailElements(galleryElement);

            // define options (if needed)
            options = {
                // define gallery index (for URL)
                galleryUID: galleryElement.getAttribute('data-pswp-uid'),
                getThumbBoundsFn: function(index) {
                    // See Options -> getThumbBoundsFn section of documentation for more info
                    var thumbnail = items[index].el.getElementsByTagName('img')[0], // find thumbnail
                            pageYScroll = window.pageYOffset || document.documentElement.scrollTop,
                            rect = thumbnail.getBoundingClientRect();

                    return {x: rect.left, y: rect.top + pageYScroll, w: rect.width};
                }

            };

            // PhotoSwipe opened from URL
            if (fromURL) {
                if (options.galleryPIDs) {
                    // parse real index when custom PIDs are used
                    // http://photoswipe.com/documentation/faq.html#custom-pid-in-url
                    for (var j = 0; j < items.length; j++) {
                        if (items[j].pid == index) {
                            options.index = j;
                            break;
                        }
                    }
                } else {
                    // in URL indexes start from 1
                    options.index = parseInt(index, 10) - 1;
                }
            } else {
                options.index = parseInt(index, 10);
            }

            // exit if index not found
            if (isNaN(options.index)) {
                return;
            }

            if (disableAnimation) {
                options.showAnimationDuration = 0;
            }

            // Pass data to PhotoSwipe and initialize it
            gallery = new PhotoSwipe(pswpElement, PhotoSwipeUI_Default, items, options);
            gallery.init();
        };

        // loop through all gallery elements and bind events
        var galleryElements = document.querySelectorAll(gallerySelector);

        for (var i = 0, l = galleryElements.length; i < l; i++) {
            galleryElements[i].setAttribute('data-pswp-uid', i + 1);
            galleryElements[i].onclick = onThumbnailsClick;
        }

        // Parse URL and open gallery if it contains #&pid=3&gid=1
        var hashData = photoswipeParseHash();
        if (hashData.pid && hashData.gid) {
            openPhotoSwipe(hashData.pid, galleryElements[ hashData.gid - 1 ], true, true);
        }
    };

    // execute above function
    initPhotoSwipeFromDOM('.my-gallery');
</script>
<!--选择地址-->
<script type="text/javascript">

    /*   var data= {
     "code": 200,
     "msg": [
     {
     "contacts": "summy",
     "contactsPhone": "172615362712",
     "address": "浙江省杭州市江干区白杨街道",
     "addressId": "1"
     },
     {
     "contacts": "旧事不挽",
     "contactsPhone": "172615328372",
     "address": "北京市天安门",
     "addressId": "2"
     },
     {
     "contacts": "小天才",
     "contactsPhone": "198715362712",
     "address": "浙江省杭州市西湖区",
     "addressId": "3"
     }
     ]
     } */

    var imageUrl=[],storeImageUrl=[];
    $(function(){
        $.ajax({
            type: "post",
            url: '/randomdelivery/userManageController/address',
            data: {},
            datatype: "json",
            success: function (data) {
                address(data);
            }

        });
        // address(data);
    })


    function address(data){
        $.each(data.msg,function(num,address){
            $("#addressUl").append(' <li class="line" onclick="sure(this)" addressId="'+address.addressId+'">\
                    <div class="aui-card-list-content-padded">\
                    <div style="float: left">'+address.contacts+'</div>' +
                    '<div style="float:right;">'+address.contactsPhone+'</div><br>\
                    <div style="margin-top: 5px">'+address.address+'</div>\
                    </div>\
                    </li>')
        })
    }
    $("#storeMap").on("click",function(){
        $("#map").show();
        $("#pubBuy").css("display","none");
    })
    function backMap(){
        $("#pubBuy").css("display","block");
        $("#map").css("display","none");
    }
    function changeAddr(){
        $("#pubBuy").css("display","none");
        $("#addr").css("display","block");
    }
    function back(){
        $("#pubBuy").css("display","block");
        $("#addr").css("display","none");
    }

    function sure(node){
        var addressId = node.getAttribute("addressId");
        var div = node.firstElementChild;
        var name = div.firstElementChild;
        var phone = name.nextElementSibling;
        var address = div.lastElementChild;
        //alert(address.innerHTML);
        $("#address").html(address.innerHTML);
        $("#address").attr("addressId",addressId);
        $("#phone").html(phone.innerHTML);
        $("#name").html(name.innerHTML);

        $("#pubBuy").css("display","block");
        $("#addr").css("display","none");
    }

    function ajaxFileUpload() {
        /* var files = document.getElementById("head_file_ipt").files;
         for(var i=0; i< files.length; i++){
         alert(head_file_ipt.files[i].name);
         }*/
        $.ajaxFileUpload({
            url : '/randomdelivery/userManageController/moreImageUpload?temp=1', //用于文件上传的服务器端请求地址
            secureuri : false, //是否需要安全协议，一般设置为false
            fileElementId : 'head_file_ipt', //文件上传域的ID
            dataType : 'json', //返回值类型 一般设置为json
            contentType:'x-www-form-urlencoded',
            success : function(data) { //服务器成功响应处理函数
                // alert(JSON.stringify(data));
                $.each(data.msg,function(num,data) {
                    $("#purchaseImg").append(' <figure>\
                                <a href="' + data + '" data-size="800x1142">\
                                <img style="width: 60px;height:60px;" src="' + data + '" >\
                                </a>\
                                </figure>');
                    storeImageUrl.push(data);
                })
                //alert(imageUrl);

            },
            error : function(data, status, e) { //服务器响应失败处理函数
                alert(JSON.stringify(data));
                alert(status);
                alert(e);
            }
        });
    }
    function ajaxFileUpload1() {
        /* var files = document.getElementById("head_file_ipt").files;
         for(var i=0; i< files.length; i++){
         alert(head_file_ipt.files[i].name);
         }*/
        $.ajaxFileUpload({
            url : '/randomdelivery/userManageController/moreImageUpload?temp=0', //用于文件上传的服务器端请求地址
            secureuri : false, //是否需要安全协议，一般设置为false
            fileElementId : 'head_file_ipt1', //文件上传域的ID
            dataType : 'json', //返回值类型 一般设置为json
            contentType:'x-www-form-urlencoded',
            success : function(data) { //服务器成功响应处理函数
                // alert(JSON.stringify(data));
                $.each(data.msg,function(num,data) {
                    $("#tradeImg").append(' <figure>\
                                  <a href="' + data + '" data-size="800x1142">\
                                  <img style="width: 60px;height:60px;" src="' + data + '" >\
                                  </a>\
                                  </figure>');
                    imageUrl.push(data);
                })

            },
            error : function(data, status, e) { //服务器响应失败处理函数
                alert(JSON.stringify(data));
                alert(status);
                alert(e);
            }
        });
    }

    $("#pubOrder").on("click",function(){
        var tradeName = $("#tradeName").val();
        if(tradeName==""){
            $("#words").html("请输入商品名");
            $(".mask").show().delay(2000).hide(300);
            return false;
        }
        var purchaseStore = $("#purchaseStore").val();
        if(purchaseStore==""){
            $("#words").html("请输入店铺名");
            $(".mask").show().delay(2000).hide(300);
            return false;
        }
        var purchasePlace=$("#purchasePlace").val();
        if(purchasePlace==""){
            $("#words").html("请输入店铺地址");
            $(".mask").show().delay(2000).hide(300);
            return false;
        }
        var storeLongitude = sessionStorage.getItem("storeLongitude");
        var storeLatitude = sessionStorage.getItem("storeLatitude");
        alert(storeLatitude);
        // alert(lat);
        var addressId = $("#address").attr("addressId");
        if(addressId==""){
            $("#words").html("请输入收货地址");
            $(".mask").show().delay(2000).hide(300);
            return false;
        }
        var expectedArrivalTime = $("#time").val() +":00";
        if(expectedArrivalTime==""){
            $("#words").html("请输入期望送达时间");
            $(".mask").show().delay(2000).hide(300);
            return false;
        }
        var reward = $("#tips").val();//小费

        var estimateThePrice = $("#goods").val();//预估金额

        var courierFees = $("#express").val();//快递费

        var note = $("#note").val();
        var picture = "qwe";

        var userId =sessionStorage.getItem("userId");
        // alert(tradeName);
        // alert(purchaseStore);alert(imageUrl);alert(purchasePlace);alert(storeImageUrl);alert(addressId);
        //alert(expectedArrivalTime);alert(reward);alert( estimateThePrice);alert(courierFees);alert(note);

        $.ajax({
            type: "post",
            url: '/randomdelivery/userDemandController/releaseSun',
            traditional: true,
            data: {
            	purchaseUserId:1,
                tradeName:tradeName,
                purchaseStore:purchaseStore,
                imageUrl:imageUrl,
                storeImageUrl:storeImageUrl,
                purchasePlace:purchasePlace,
                addressId:addressId,
                expectedArrivalTime:expectedArrivalTime,
                reward:reward,
                estimateThePrice:estimateThePrice,
                courierFees:courierFees,
                note:note,
                storeLongitude:storeLongitude,
                storeLatitude:storeLatitude

            },
            datatype: "json",
            success: function (data) {
                //alert(JSON.stringify(data));
                sessionStorage.setItem("demandId", data.msg.demandId);
                location.href="orderDetails.html";
            }
        });
        /*  sessionStorage.setItem("demandId", data.msg.demandId);
         location.href="orderDetails.html"; */
    })


</script>
<!--选择时间-->
<script type="text/javascript">
    $(function () {
        var curr = new Date().getFullYear();
        var opt={};
        opt.date = {preset : 'date'};
        opt.datetime = {preset : 'datetime'};
        opt.time = {preset : 'time'};

        opt.default = {
            theme: 'android-holo light', //皮肤样式
            display: 'bottom', //显示方式
            mode: 'scroller', //日期选择模式
            dateFormat: 'yyyy-mm-dd',
            lang: 'zh',
            showNow: true,
            nowText: "现在",
            stepMinute: 5,
            startYear: curr - 0, //开始年份
            endYear: curr + 0 //结束年份
        };
        $('.settings').bind('change', function() {
            var demo = 'datetime';
            if (!demo.match(/select/i)) {
                $('.demo-test-' + demo).val('');
            }
            $('.demo-test-' + demo).scroller('destroy').scroller($.extend(opt['datetime'], opt['default']));
            $('.demo').hide();
            $('.demo-' + demo).show();
        });
        $('#demo').trigger('change');
    });
</script>



</body>
</html>